package com.demo2do.fms.entity.supplier.ware;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.springframework.format.annotation.DateTimeFormat;

import com.demo2do.core.format.PersistentFormat;
import com.demo2do.fms.entity.supplier.common.Supplier;

/**
 * 仓储服务供方 现场人员
 * 
 * 与supplier：一对多
 * 
 * Created by zhonghui on 2017/7/13.
 */
@Entity
@Table(name = "FMS_WARE_SUPPLIERE_EMPLOYEE")
public class WareSupplierEmployee {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "generator")
    @SequenceGenerator(name = "generator", sequenceName = "HIBERNATE_SEQUENCE", allocationSize = 1)
    private Long id;

    /** 与supplier关联 */
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @PersistentFormat
    private Supplier supplier;

    private String key;

    private String name;

    private Long value;

    /**
     * 是否注销
     */
    @Column(name = "IS_DISABLED")
    private Boolean disabled;

    /**
     * 创建时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /**
     * 创建者
     */
    private Long creator;

    /**
     * 最近修改时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date lastModifyTime;

    /**
     * 最近修改者
     */
    private Long lastOperator;

    /**
     * Instantiates a new Storage staff info.
     */
    public WareSupplierEmployee() {
    }

    /**
     * 
     * @param supplier
     */
    public WareSupplierEmployee(Supplier supplier) {
        this.supplier = supplier;
    }
    
    /**
     * 
     * @param supplier
     * @param key
     * @param name
     * @param value
     */
    public WareSupplierEmployee(Supplier supplier ,String key,String name,Long value) {
        this.supplier = supplier;
        this.key=key;
        this.name=name;
        this.value=value;
    }
    
    /**
     * 
     * @param value
     * @return
     */
    public WareSupplierEmployee edit(Long value) {

        this.value=value;
        this.lastModifyTime = new Date();
        this.lastOperator = null;

        return this;
    }

    /**
     * 
     * @return
     */
    public WareSupplierEmployee create() {

        this.createTime = new Date();
        this.lastModifyTime = new Date();
        this.creator=new Long(1);
        this.lastOperator = this.creator;
        this.disabled = false;

        return this;
    }

    /**
     * Gets id.
     *
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * Gets supplier.
     *
     * @return the supplier 
     */
    public Supplier getSupplier() {
        return supplier;
    }

    /**
     * Gets key.
     *
     * @return the key
     */
    public String getKey() {
        return key;
    }

    /**
     * Gets name.
     *
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * Gets value.
     *
     * @return the value
     */
    public Long getValue() {
        return value;
    }

    /**
     * Gets disabled.
     *
     * @return the disabled
     */
    public Boolean getDisabled() {
        return disabled;
    }

    /**
     * Gets create time.
     *
     * @return the create time
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * Gets creator.
     *
     * @return the creator
     */
    public Long getCreator() {
        return creator;
    }

    /**
     * Gets last modify time.
     *
     * @return the last modify time
     */
    public Date getLastModifyTime() {
        return lastModifyTime;
    }

    /**
     * Gets last operator.
     *
     * @return the last operator
     */
    public Long getLastOperator() {
        return lastOperator;
    }

    /**
     * Sets id.
     *
     * @param id the id
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * Sets supplier .
     *
     * @param supplier the supplier
     */
    public void setSupplier(Supplier supplier) {
        this.supplier = supplier;
    }

    /**
     * Sets key.
     *
     * @param key the key
     */
    public void setKey(String key) {
        this.key = key;
    }

    /**
     * Sets name.
     *
     * @param name the name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * Sets value.
     *
     * @param value the value
     */
    public void setValue(Long value) {
        this.value = value;
    }

    /**
     * Sets disabled.
     *
     * @param disabled the disabled
     */
    public void setDisabled(Boolean disabled) {
        this.disabled = disabled;
    }

    /**
     * Sets create time.
     *
     * @param createTime the create time
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * Sets creator.
     *
     * @param creator the creator
     */
    public void setCreator(Long creator) {
        this.creator = creator;
    }

    /**
     * Sets last modify time.
     *
     * @param lastModifyTime the last modify time
     */
    public void setLastModifyTime(Date lastModifyTime) {
        this.lastModifyTime = lastModifyTime;
    }

    /**
     * Sets last operator.
     *
     * @param lastOperator the last operator
     */
    public void setLastOperator(Long lastOperator) {
        this.lastOperator = lastOperator;
    }
}
